package net.kesumu.yushabu.storage;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class YushabuDbHelper extends SQLiteOpenHelper{
    
    public static final int DATABASE_VERSION = 1;
    public static final String DATABASE_NAME = "yushabu.db";
    
    public static final String SEMICOLON = "; ";
    
//    public static final String SQL_CREATE_ENTRIES = 
//                                FriendContract.SQL_CREATE_ENTRY_FRIEND + SEMICOLON + 
//                                YushabuSessionContract.SQL_CREATE_ENTRY_YUSHABUSESSION + SEMICOLON + 
//                                YushabuMessageContract.SQL_CREATE_ENTRY_YUSHABUMESSAGE + SEMICOLON;
//    
//    public static final String SQL_DELETE_ENTRIES = 
//                                FriendContract.SQL_DELETE_ENTRY_FRIEND + SEMICOLON + 
//                                YushabuSessionContract.SQL_DELETE_ENTRY_YUSHABUSESSION + SEMICOLON + 
//                                YushabuMessageContract.SQL_DELETE_ENTRY_YUSHABUMESSAGE + SEMICOLON;
    
    public YushabuDbHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(FriendContract.SQL_CREATE_ENTRY_FRIEND);
        db.execSQL(YushabuSessionContract.SQL_CREATE_ENTRY_YUSHABUSESSION);
        db.execSQL(YushabuMessageContract.SQL_CREATE_ENTRY_YUSHABUMESSAGE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //here may be modified for future use
        db.execSQL(FriendContract.SQL_DELETE_ENTRY_FRIEND);
        db.execSQL(YushabuSessionContract.SQL_DELETE_ENTRY_YUSHABUSESSION);
        db.execSQL(YushabuMessageContract.SQL_DELETE_ENTRY_YUSHABUMESSAGE);
        onCreate(db);
    }
    public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        onUpgrade(db, oldVersion, newVersion);
    }
}
